#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author Jmz





info = '''
global x
x = 1
y = 12 
def foo():
    return "foo"
'''


# exec功能：执行python 字符串代码，自定义全局名称空间，自定义局部名称空间
globals_dict = {"x":1000}

locals_dict = {}

exec(info,globals_dict,locals_dict)


print(globals_dict)  # 全局内容
print(locals_dict)      #局部名称空间


print(locals_dict['foo']())


